#include <clusnet/base/Timestamp.h>
#include <gtest/gtest.h>

#include <array>

using namespace clusnet::base;

std::string passByConstReference(const Timestamp& x)
{
    return x.toString();
}

std::string passByValue(Timestamp x)
{
    return x.toString();
}

TEST(Timestamp, passByConstReference)
{
    Timestamp now(Timestamp::now());
    ASSERT_EQ(now.toString(), passByConstReference(now));
}

TEST(Timestamp, passByValue)
{
    Timestamp now(Timestamp::now());
    ASSERT_EQ(now.toString(), passByValue(now));
}

TEST(Timestamp, compareOperator)
{
    Timestamp ts1(Timestamp::now());
    Timestamp ts2(addTime(ts1, 200));
    ASSERT_DOUBLE_EQ(timeDifference(ts2, ts1), 200);
    ASSERT_TRUE(ts1 < ts2);
    ASSERT_FALSE(ts2 < ts1);
    ASSERT_FALSE(ts1 == ts2);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return  RUN_ALL_TESTS();
}
